package cn.tedu.imop.mq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FanoutExchangeConfig {

    @Bean
    public FanoutExchange fanoutExchange(){
        return new FanoutExchange("exc.fanout");
    }
    @Bean
    public Queue createQueue1(){
        return new Queue("fanout.queue1");
    }
    @Bean
    public Queue createQueue2(){
        return new Queue("fanout.queue2");
    }

    @Bean
    public Binding bindingQueue1(Queue createQueue1, FanoutExchange fanoutExchange){
        return BindingBuilder.bind(createQueue1).to(fanoutExchange);
    }
    @Bean
    public Binding bindingQueue2(Queue createQueue2, FanoutExchange fanoutExchange){
        return BindingBuilder.bind(createQueue2).to(fanoutExchange);
    }
}
